<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of Menu
 *
 * @author dliebel
 */
namespace Application\Model;
use Zend\Db\Adapter\Adapter;
use Application\Utils\GenericManager;
//validaciones
 use Zend\InputFilter\InputFilter;
 use Zend\InputFilter\InputFilterAwareInterface;
 use Zend\InputFilter\InputFilterInterface;

class Menu extends GenericManager implements InputFilterAwareInterface{
    //put your code here
    private $id;
    private $menuPadreId;
    private $titulo;
    private $descripcion;
    private $comando;
    protected $inputFilter;
    
     public function __construct($nameTable ,Adapter $adapter = null, $databaseSchema = null, ResultSet $selectResultPrototype = null)
    {
        return parent::__construct($nameTable, $adapter, $databaseSchema,$selectResultPrototype);
    }
    
    public function exchangeArray($data) {
        $this->id = (!empty($data['id'])) ? $data['id'] : null;
        $this->menuPadreId = (!empty($data['menuPadreId'])) ? $data['menuPadreId'] : null;
        $this->titulo = (!empty($data['titulo'])) ? $data['titulo'] : null;
        $this->descripcion = (!empty($data['descripcion'])) ? $data['descripcion'] : null;
        $this->comando = (!empty($data['comando'])) ? $data['comando'] : null;
        
        if ( $this->id==0){
             $this->id=null;
        }
        if ( $this->menuPadreId==0){
             $this->menuPadreId=null;
        }
        $data=array
        (
            "titulo"=> $this->titulo,
            "descripcion"=>$this->descripcion,
            "comando"=>$this->comando,
            "menu_id"=>$this->menuPadreId 
            
        );
        return $data;
    }
    
    
    public function getId() {
        return $this->id;
    }

    public function setId($id) {
        $this->id = $id;
    }

    public function getMenuPadreId() {
        return $this->menuPadreId;
    }

    public function setMenuPadreId($menuPadreId) {
        $this->menuPadreId = $menuPadreId;
    }

    public function getTitulo() {
        return $this->titulo;
    }

    public function setTitulo($titulo) {
        $this->titulo = $titulo;
    }

    public function getDescripcion() {
        return $this->descripcion;
    }

    public function setDescripcion($descripcion) {
        $this->descripcion = $descripcion;
    }

    public function getComando() {
        return $this->comando;
    }

    public function setComando($comando) {
        $this->comando = $comando;
    }

    
     
    
     public function setInputFilter(InputFilterInterface $inputFilter) 
    { 
        throw new \Exception("Not used"); 
    } 
    
     public function getInputFilter()
     {
         if (!$this->inputFilter) {
             $inputFilter = new InputFilter();

             $inputFilter->add(array(
                 'name'     => 'id',
                 'required' => true,
                 'filters'  => array(
                     array('name' => 'Int'),
                 ),
             ));

             $inputFilter->add(array(
                 'name'     => 'titulo',
                 'required' => true,
                 'filters'  => array(
                     array('name' => 'StripTags'),
                     array('name' => 'StringTrim'),
                 ),
                 'validators' => array(
                     array(
                         'name'    => 'StringLength',
                         'options' => array(
                             'encoding' => 'UTF-8',
                             'min'      => 1,
                             'max'      => 20,
                         ),
                     ),
                 ),
             ));

             $inputFilter->add(array(
                 'name'     => 'descripcion',
                 'required' => true,
                 'filters'  => array(
                     array('name' => 'StripTags'),
                     array('name' => 'StringTrim'),
                 ),
                 'validators' => array(
                     array(
                         'name'    => 'StringLength',
                         'options' => array(
                             'encoding' => 'UTF-8',
                             'min'      => 1,
                             'max'      => 100,
                         ),
                     ),
                 ),
             ));

             $this->inputFilter = $inputFilter;
         }

         return $this->inputFilter;
     }
    
    
  
       
    
    
}

?>
